package com.tongfusoft.document.personalCenter.myFavorite.service.impl;

import java.sql.Timestamp;
import java.util.Date;

import org.springframework.stereotype.Service;

import com.tongfusoft.da.pagehelper.PageInfo;
import com.tongfusoft.da.template.service.impl.DataTemplateServiceImpl;
import com.tongfusoft.document.entity.Docs;
import com.tongfusoft.document.entity.UserFavorites;
import com.tongfusoft.document.entity.Users;
import com.tongfusoft.document.personalCenter.myFavorite.service.IMyFavoriteService;
import com.tongfusoft.utils.UIDGeneratorService;

@Service("iMyFavoriteService")
public class MyFavoriteServiceImpl extends DataTemplateServiceImpl<Docs> implements IMyFavoriteService {

	@Override
	public PageInfo<Docs> favoriteList(UserFavorites favorites, Users user, int pageSize,
			int pageIndex) {
		favorites.setCreatedBy(user.getUserId());
		favorites.setSelectUser(user.getUserId());
		return super.findPage("favoriteList", favorites, pageSize, pageIndex);
	}


	@Override
	public void deleteUserFavorites(UserFavorites favorites) {
		super.delete("deleteUserFavorites", favorites);
		
	}


	@Override
	public void createUserFavorites(UserFavorites favorites, Users user) {
		favorites.setFavoriteId(UIDGeneratorService.getUUID());
		favorites.setCreatedBy(user.getUserId());
		favorites.setCreatedDate(new Timestamp(new Date().getTime()));
		favorites.setStatus("1");
		favorites.setLastUpdBy(user.getUserId());
		favorites.setLastUpdDate(new Timestamp(new Date().getTime()));
		this.insert("createUserFavorites",favorites);
	}


	@Override
	public UserFavorites getUserFavorite(UserFavorites favorites) {
		
		return this.selectOne("getUserFavorite", favorites);
	}



}
